#include<iostream>
#include<vector>
#include<string>
#include<cstdio>
#include<stdlib.h>
#include<unistd.h>
#include<sys/types.h>
#include<sys/wait.h>
using namespace std;

extern char** environ;

const string myenv = "HELLO=AAAAAA";

int main()
{
  putenv((char*)myenv.c_str());
  pid_t id = fork();
  if(id == 0)
  {
    // sleep(3);
     char* const argv[] = {
       (char*)"other",
       nullptr 
     };
    
     char* const env[] = {
       (char*)"HELLO=bite",
       (char*)"HELLO1=bite1",
       (char*)"HELLO2=bite2",
       (char*)"HELLO3=bite3"
     };
     execvpe("./other",argv,environ);
     // execvp("ls",argv);
     //   execlp("ls","ls","-l","--color","-a",nullptr);
  //   execv("/usr/bin/ls",argv); 

   //  execl("/bin/ls","ls","-l","--color","-a",nullptr); 
     exit(1);
  }
  pid_t rid = waitpid(id,nullptr,0);
  if(rid > 0)
  {
    printf("等待成功，rid:%d\n",rid);
  }
  else 
  {
    printf("等待失败\n");
  }
 


 //   printf("我的pid: %d\n",getpid());
 //  // int n = execl("./other","other",nullptr);
 //   int n = execl("/bin/lsss","lssss",nullptr);
 //   printf("n：%d\n",n);
////  execl("/bin/pwd","pwd",nullptr);
  return 0;
}
